package com.example.cat.chinagirl918;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextClock;

import com.example.cat.chinagirl918.Utils.IntentHelper;
import com.example.cat.chinagirl918.Utils.NewImgAdapter;
import com.example.cat.chinagirl918.Utils.PrintLogHelper;
import com.umeng.analytics.MobclickAgent;


public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private TextClock timePicker;
    private Button getmorebutton;
    private Button about;
    private WebView LocalWebview;

    private Button addfriend;

    private ImageView MainViewImg;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        InitView();
        InitWebView();

    }

    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }

    private void InitView() {

    try{
        addfriend = findViewById(R.id.addfriend);
        getmorebutton = findViewById(R.id.getmorebutton);
        about = findViewById(R.id.about);

        LocalWebview = findViewById(R.id.LocalWebview);
        timePicker = findViewById(R.id.timePicker);
        LocalWebview = findViewById(R.id.LocalWebview);
        MainViewImg = findViewById(R.id.MainViewImg);
        MainViewImg.setImageBitmap(new NewImgAdapter().GetBitMap(0));
        about.setOnClickListener(this);
        getmorebutton.setOnClickListener(this);
        addfriend.setOnClickListener(this);
    }catch (Exception ex){

        PrintLogHelper.OutLog(ex);
    }

    }

    private void InitWebView() {
        LocalWebview.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                super.onProgressChanged(view, newProgress);

            }
        });
        LocalWebview.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                return super.shouldOverrideUrlLoading(view, request);
            }
        });
        LocalWebview.loadUrl("http://www.acg12.net/wp-content/uploads/2018/05/adjump.html");
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.about:
                IntentHelper.OpenWebBower("http://www.acg12.net/?p=1324");
                break;
            case R.id.getmorebutton:
                IntentHelper.OpenWebBower("http://www.acg12.net/wp-content/uploads/2018/05/morejump.html");
                break;
            case R.id.addfriend:
                IntentHelper.OpenWebBower("http://www.acg12.net/wp-content/uploads/2018/05/addfriends.html");

        }
    }
}
